#include<bits/stdc++.h>
using namespace std;
int n,m,l,V,T;
int d[100050],v[100050],a[100050],b[100050],e[100050],ip,cf[100050],qzh[100050],lb[100050],ub[100050],cp;
bool pded[100050];
vector<int> p;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        p.erase(p.begin(),p.end());
        cin>>n>>m>>l>>V;
        for(int i=0;i<n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
            if(v[i]<=V and a[i]<=0)
            {
                i--;
                n--;
            }
            else if(v[i]>V and a[i]>=0)
            {
                b[i]=d[i];
                e[i]=l;
            }
            else if(v[i]==V and a[i]>0)
            {
                b[i]=d[i]+1;
                e[i]=l;
            }
            else if(v[i]<V)
            {
                b[i]=d[i]+floor((double)(V*V-v[i]*v[i])/(2*a[i])+1);
                e[i]=l;
                if(b[i]>l)
                {
                    i--,n--;
                }
            }
            else
            {
                b[i]=d[i];
                e[i]=min(d[i]+ceil((double)(V*V-v[i]*v[i])/(2*a[i])-1),(double)l);
            }
        }
        for(int i=0;i<m;i++)
        {
            cin>>ip;
            p.push_back(ip);
        }
        sort(p.begin(),p.end());
        int ans1=0,j=0,ans2=0;
        for(int i=0;i<n;i++)
        {
            lb[j]=lower_bound(p.begin(),p.end(),b[i])-p.begin();
            ub[j]=upper_bound(p.begin(),p.end(),e[i])-p.begin();
            if(lb[j]==ub[j])
            {
                ans1++;
            }
            else
            {
                b[j]=b[i];
                e[j++]=e[i];
            }
        }
        cout<<n-ans1<<' ';
        n-=ans1;
        cp=0;
        for(int i=0;i<n;i++)
        {
            pded[i]=0;
        }
      //  for(int i=0;i<n;i++)
      //  {
      //      cout<<b[i]<<' '<<e[i]<<' '<<lb[i]<<' '<<ub[i]<<endl;
      //  }
        while(cp<n)
        {
            for(int i=0;i<=m;i++)
            {
                cf[i]=0;
                qzh[i]=0;
            }
            for(int i=0;i<n;i++)
            {
                if(pded[i])
                {
                    continue;
                }
                cf[lb[i]]++;
                cf[ub[i]]--;
            }
            qzh[0]=cf[0];
            int mn=qzh[0],mp=0;
            for(int i=1;i<m;i++)
            {
                qzh[i]=cf[i]+qzh[i-1];
          //      cout<<qzh[i]<<' '<<cf[i]<<endl;
                if(mn<qzh[i])
                {
                    mn=qzh[i];
                    mp=i;
                }
            }
        //    cout<<mn<<' '<<mp<<endl;
            for(int i=0;i<n;i++)
            {
                if(!pded[i] and b[i]<=p[mp] and p[mp]<=e[i])
                {
                    cp++;
                    pded[i]=1;
                }
            }
            ans2++;
         //   cout<<endl;
        }
        cout<<m-ans2<<'\n';
    }
    return 0;
}
